function populateNewGroupUsers(){
	populateTableForGroup("newGroupUsers","groupLoginIds")
	document.getElementById("groupLoginIds").value=""
		document.getElementById("txtGroupName").value=""	
	
}

function populateTableForGroup(tblName, selectIds,type, usersForSelectedGroup){
	deleteRows(tblName, false)
	fieldForUpdation = selectIds;
	tbl = document.getElementById(tblName)
	for(i=0; i< currentOnlineUsers.length ;i++){
		if (currentOnlineUsers[i][5] != 'Y' && currentOnlineUsers[i][4] =='APP'){
			var lastRow = tbl.rows.length;
			row = tbl.insertRow(lastRow);
			
			var cellLeft = row.insertCell(0);
			var cellCenter = row.insertCell(1);
			var cellRight = row.insertCell(2);
			
			cellLeft.innerHTML = "<img src='images/"+getSmallImageValue(trim(currentOnlineUsers[i][3]))+"' />"
			cellCenter.innerHTML = currentOnlineUsers[i][2]
			if ("UPDATE" == type && usersForSelectedGroup.contains(trim(currentOnlineUsers[i][0]))) {
				alert("Checking")
				document.getElementById(selectIds).value += trim(currentOnlineUsers[i][0])+";"
				cellRight.innerHTML = "<input checked=checked type=checkbox value='"+currentOnlineUsers[i][0]+"'   onclick=userGroupCheckBoxClicked(this,"+fieldForUpdation+") />"
			} else {
				cellRight.innerHTML = "<input type=checkbox value='"+currentOnlineUsers[i][0]+"'   onclick=userGroupCheckBoxClicked(this,"+fieldForUpdation+") />"
			}
		}
	}
}

function userGroupCheckBoxClicked(checkbox,selectIds){
	alert(selectIds.value)
	if (checkbox.checked == true){
		selectIds.value+=checkbox.value+";"
	} else {
		valu = selectIds.value
		selectIds.value= valu.replace(checkbox.value, '');
 
	}
	alert(selectIds.value)
}

function populateUpdateGroup(){
	var selectbox = document.getElementById('groupOwns');
	selectbox.length = 1;
	tbl = document.getElementById("updateGroupUsers")
	deleteRows(tblName, false)
	var exsistingUsers = document.getElementById('existingUsers');
	exsistingUsers.value ="";

	for (i=0; i< currentOnlineUsers.length;i++){
		log(currentOnlineUsers[i][2] + " " + currentOnlineUsers[i][5] + " " +  currentOnlineUsers[i][6] +" "+ localuser)
		if (currentOnlineUsers[i][5] == 'Y' && currentOnlineUsers[i][6] == localuser){	
			var optn = document.createElement("OPTION");
			optn.text = currentOnlineUsers[i][2];
			optn.value = currentOnlineUsers[i][0];
			selectbox.options.add(optn);
								
		}
	}
}
function populateUpdateGroupUsers(selectedGroup){
	
	var exsistingUsers = document.getElementById('existingUsers');
	exsistingUsers.value ="";
	var availableUsers = document.getElementById('availableUsers');
	availableUsers.value =""
	usersForSelectedGroup = new Array();
	for(i=0; i< groupUsers.length;i++){
		if (groupUsers[i][7] == selectedGroup){
			usersForSelectedGroup.push(groupUsers[i][0])
		}
		
	}
	alert(usersForSelectedGroup)

	populateTableForGroup("updateGroupUsers","existingUsers","UPDATE", usersForSelectedGroup)
	
			
}